﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Scoreboard.Interfaces;

using Microsoft.Practices.Composite.Events;
using Scoreboard.Basement.Events;
using Scoreboard.Basement;
using Scoreboard.Basement.Views;
using Scoreboard.Basement.ViewModels;
using Scoreboard.Basement.Controls;
using System.Collections.Generic;

namespace Scoreboard.Dialog
{
	public class DialogService : IDialogService
	{	
		public void ShowMessage(string message)
		{
			ShowMessage("Сообщение", message);
		}

		public void ShowMessage(string header, string message)
		{ 		
			var viewModel = new MessageDialogViewModel(message)
			{
				InitialTitle = header,
				HasCloseButton = true
			};

			var eventArgs = new ShowDialogEventArgs(new MessageDialog(viewModel));
			ShowDialog(eventArgs);
		}

		public void ShowDialog(DialogBase dialog)
		{
			ShowDialog(new ShowDialogEventArgs(dialog));
		}

		public void ShowDialog(DialogParameters parameters)
		{
			ShowDialog(new ShowDialogEventArgs(parameters));
		}

		private void ShowDialog(ShowDialogEventArgs eventArgs)
		{ 
			var eventAggregator = ServiceLocator.Get<IEventAggregator>();
			var showDialogEvent = eventAggregator.GetEvent<ShowDialogEvent>();			
			
			showDialogEvent.Publish(eventArgs);
		}
	}
}
